/* Copyright (c) 2025 Huawei Technologies Co., Ltd.
 * openUBMC is licensed under Mulan PSL v2.
 * You can use this software according to the terms and conditions of the Mulan PSL v2.
 * You may obtain a copy of Mulan PSL v2 at:
 *          http://license.coscl.org.cn/MulanPSL2
 * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
 * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
 * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
 * See the Mulan PSL v2 for more details.
 */

#ifndef __L_MEASUREMENT_SET_H__
#define __L_MEASUREMENT_SET_H__

#include <string_view>
#include <lua.hpp>
#include "luawrapper.h"
#include "common.h"

class LMeasurementSet {
public:
    string  specification;
    string  summaryType;
    string  summaryHashAlgorithm;
    string  summaryHash;
    uint8_t measurementsCount;

    LMeasurementSet(const string& specification, const string& summaryType, const string& summaryHashAlgorithm,
        const string& summaryHash, uint8_t measurementsCount)
        : specification(specification), summaryType(summaryType), summaryHashAlgorithm(summaryHashAlgorithm),
        summaryHash(summaryHash), measurementsCount(measurementsCount) {};
    ~LMeasurementSet() = default;

    std::string_view get_specification() const
    {
        return this->specification;
    }

    std::string_view get_summary_type() const
    {
        return this->summaryType;
    }

    std::string_view get_summary_hash_algo() const
    {
        return this->summaryHashAlgorithm;
    }

    std::string_view get_summary_hash() const
    {
        return this->summaryHash;
    }

    uint8_t get_measurements_count() const
    {
        return this->measurementsCount;
    }

    static void register_to(lua_State *L, luawrap::stack_table &t)
    {
        luawrap::restore_stack_top _s(L);

        auto cls = luawrap::lua_class<LMeasurementSet>(L);
        cls.def_property("specification", c_func_wrap(L, LMeasurementSet::get_specification));
        cls.def_property("summaryType", c_func_wrap(L, LMeasurementSet::get_summary_type));
        cls.def_property("summaryHashAlgorithm", c_func_wrap(L, LMeasurementSet::get_summary_hash_algo));
        cls.def_property("summaryHash", c_func_wrap(L, LMeasurementSet::get_summary_hash));
        cls.def_property("measurementsCount", c_func_wrap(L, LMeasurementSet::get_measurements_count));

        t.set("MeasurementSet", cls);
    }
};

#endif // __L_MEASUREMENT_SET_H__